/**
 * Created by zhouxiong on 16/12/16.
 */
// import Routers from '../router';
// import util from '../libs/util';
//import Vue from 'vue';
export default {
    CHANGE_TITLE(state,value) {
        state.titleInfo.title = value
    },
    CHANGE_ROUTER_HOME(state,value) {
        state.routerHome = value
    },
    CHANGE_DES(state,value) {
        state.titleInfo.des = value
    },
    CHANGE_USER(state,value) {
        state.user = Object.assign({},value)
    },
    CHANGE_YUNNAME(state,value){
        state.yunname = value
    },
    CHANGE_TOKEN(state,value) {
        state.user.token = value
    },
    CHANGE_NAME(state,value) {
        state.user.name = value
    },
    CHANGE_AVATAR(state,value) {
        state.user.avatar = value
    },
    CHANGE_PERMISSION(state,value) {
        state.operation = value
    },
    TOGGLE_SILDE(state,value) {
        state.sildeshow = value
    },
    CHANGE_SIDE(state,value) {
        state.toggle = value
    },
    CHANGE_ACTIONS(state,value) {
        state.actions = value
    },
    CHANGE_SOCKET(state,value) {
        let _type = value.type
        if(!state.socket[_type]){
            state.socket[_type] = 0
            //Vue.set(state.socket,_type,0)
            state.socket = Object.assign({},state.socket)
        }
        state.socket[_type] = value.progress
        //state.socket = Object.assign({},state.socket)
    },

    CHANGE_PROVINCE(state,value) {
        state.carinfo.provinceCode = value.province
        state.carinfo.cityCode = value.cityCode
    },  

    CHANGE_RESPONSENO(state,value){
        state.carinfo.responseNo = value
    },

    CHANGE_CARINFO(state,value){
        state.carinfo = Object.assign({},state.carinfo,value)
    },

    CHANGE_CARTYPE(state,value){
        state.cartype = value
    },

    CHANGE_CARQUOTE(state,value){
        state.carQuote = Object.assign({},state.carQuote,value)
    }


    // setTagsList (state, list) {
    //     state.tagsList.push(...list);
    // },
    // closePage (state, name) {
    //     state.cachePage.forEach((item, index) => {
    //         if (item === name) {
    //             state.cachePage.splice(index, 1);
    //         }
    //     });
    // },
    // initCachepage (state) {
    //     if (localStorage.cachePage) {
    //         state.cachePage = JSON.parse(localStorage.cachePage);
    //     }
    // },
    // setOpenedList (state) {
    //     state.pageOpenedList = localStorage.pageOpenedList ? JSON.parse(localStorage.pageOpenedList) : [Routers[0].children[0]];
    // },
    // removeTag (state, name) {
    //     state.pageOpenedList.map((item, index) => {
    //         if (item.name === name) {
    //             state.pageOpenedList.splice(index, 1);
    //         }
    //     });
    // },
    // pageOpenedList (state, get) {
    //     let openedPage = state.pageOpenedList[get.index];
    //     if (get.argu) {
    //         openedPage.argu = get.argu;
    //     }
    //     if (get.query) {
    //         openedPage.query = get.query;
    //     }
    //     state.pageOpenedList.splice(get.index, 1, openedPage);
    //     localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
    // },
    // clearAllTags (state) {
    //     state.pageOpenedList.splice(1);
    //     state.cachePage.length = 0;
    //     localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
    // },
    // clearOtherTags (state, vm) {
    //     let currentName = vm.$route.name;
    //     let currentIndex = 0;
    //     state.pageOpenedList.forEach((item, index) => {
    //         if (item.name === currentName) {
    //             currentIndex = index;
    //         }
    //     });
    //     if (currentIndex === 0) {
    //         state.pageOpenedList.splice(1);
    //     } else {
    //         state.pageOpenedList.splice(currentIndex + 1);
    //         state.pageOpenedList.splice(1, currentIndex - 1);
    //     }
    //     let newCachepage = state.cachePage.filter(item => {
    //         return item === currentName;
    //     });
    //     state.cachePage = newCachepage;
    //     localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
    // },
    // setCurrentPageName (state, name) {
    //     state.currentPageName = name;
    // },
    // increateTag (state, tagObj) {       
    //     if (!util.oneOf(tagObj.name, state.dontCache)) {
    //         state.cachePage.push(tagObj.name);
    //         localStorage.cachePage = JSON.stringify(state.cachePage);
    //     }
    //     state.pageOpenedList.push(tagObj);
    //     localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
    // }
}
